package com.itheima.stock.job;

import com.itheima.stock.task.StockTimerTaskService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;

/**
 * 定义股票相关数据的定时任务
 * @author laofang
 */
@Component
@Slf4j
public class StockTimerTask {

    @Autowired
    private StockTimerTaskService stockTimerTaskService;



    private static Logger logger = LoggerFactory.getLogger(StockTimerTask.class);

    @XxlJob("heima_job_test")
    public void jobTest(){

       log.info("当前时间点:{}",DateTime.now().toString(DateTimeFormat.forPattern("yyyyMMdd HH:mm:ss"))) ;
    }

    public void init(){
        logger.info("init");
    }

    public void destroy(){
        logger.info("destory");
    }


    /**
     * 定时采集A股数据
     */
    @XxlJob("getStockInfos")
    public void getStockInfos(){
        stockTimerTaskService.getInnerMarkInfo();
    }

    /**
     * 板块定时任务
     */
    @XxlJob("getStockBlockInfoTask")
    public void getStockBlockInfoTask(){

        stockTimerTaskService.getStockBlockInfos();
    }


    @XxlJob("getInnerEveryStockTask")
    public void getInnerEveryStockTask(){

        stockTimerTaskService.getInnerEveryStockInfos();
    }


}